# 1. 添加cmake版本说明
cmake_minimum_required(VERSION 3.1.3)
# 2. 声明工程名称
project(test)

# # 设置构建类型为Debug，生成调试信息
# if(NOT CMAKE_BUILD_TYPE)
#     set(CMAKE_BUILD_TYPE Debug CACHE STRING "选择构建类型: Debug, Release, RelWithDebInfo, MinSizeRel" FORCE)
# endif()

# # 为Debug构建类型添加调试标志
# set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -O0")  # 添加-g并禁用优化

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)  # 强制要求 C++17，不存在则报错
set(CMAKE_CXX_EXTENSIONS OFF)  # 禁用编译器扩展（如 gnu++17）

set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} /usr/local/lib)

set(test "test")

set(odb_path ${CMAKE_CURRENT_SOURCE_DIR}/../../../odb)
set(common_path ${CMAKE_CURRENT_SOURCE_DIR}/../../../common)
set(util_path ${CMAKE_CURRENT_SOURCE_DIR}/../../../util)

# 4. 获取源码目录下的所有源码文件
set(test_src_files "")
aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR} test_src_files)

# 5. 声明目标及依赖
list(APPEND test_src_files ${common_path}/elastic.cpp
                           ${common_path}/log.cpp
                           ${common_path}/data_es.cpp
                           ${util_path}/cjson.cpp
                           )

# 7. 设置需要连接的库
add_executable(${test} ${test_src_files} ${odb_srcs})
target_link_libraries(${test} -lspdlog -lfmt -lgflags -lcpr -lelasticlient /usr/local/lib/libjsoncpp.so)
                                
# 6. 设置头文件默认搜索路径
include_directories(${CMAKE_CURRENT_BINARY_DIR})
include_directories(${odb_path})
include_directories(${common_path})
include_directories(${util_path})
include_directories(${CMAKE_CURRENT_SOURCE_DIR})

#8. 设置安装路径
# INSTALL(TARGETS main RUNTIME DESTINATION bin)